package com.aloha.springframework.context.support;

import com.aloha.springframework.beans.factory.support.DefaultListableBeanFactory;
import com.aloha.springframework.beans.factory.xml.XmlBeanDefinitionReader;

/**
 * @author DaiZhiHeng
 * @description 使用XML加载BeanDefinition, 并将获取Resource的位置的能力交给子类去完成
 * @date 2023/7/3 9:25
 */
public abstract class AbstractXmlApplicationContext extends AbstractRefreshableApplicationContext {

    @Override
    protected void loadBeanDefinitions(DefaultListableBeanFactory beanFactory) {
        XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(beanFactory);
        String[] location = getConfigLocation();
        if (location != null) {
            reader.loadBeanDefinitions(location);
        }
    }

    protected abstract String[] getConfigLocation();

}
